package strings

import "math/rand"

type CasualLevel uint32

const (
	CasualNumber CasualLevel = iota
	CasualLetter
	CasualNumberAndLetter
	CasualNumberAndLetterAndSymbol

	bytesNumber                   = "0123456789"
	bytesLetter                   = "abcdefghijklmnopqrstuvwxyz"
	bytesNumberAndLetter          = "0123456789abcdefghijklmnopqrstuvwxyz"
	bytesNumberAndLetterAndSymbol = "0123456789abcdefghijklmnopqrstuvwxyz_-+/*&%"
)

func BuildCasualString(level CasualLevel, length int) string {
	var options string
	switch level {
	case CasualNumber:
		options = bytesNumber
	case CasualLetter:
		options = bytesLetter
	case CasualNumberAndLetter:
		options = bytesNumberAndLetter
	case CasualNumberAndLetterAndSymbol:
		options = bytesNumberAndLetterAndSymbol
	}

	b := make([]byte, length)
	for i := range b {
		b[i] = options[rand.Int31()%int32(len(options))]
	}
	return string(b)
}
